package com.hs.communication.common.fallback;

import com.hs.common.core.domain.Result;
import com.hs.communication.common.entity.dto.ParaDto;
import com.hs.communication.common.feign.RemoteMqttService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class RemoteMqttFallbackFactory implements FallbackFactory<RemoteMqttService> {

    @Override
    public RemoteMqttService create(Throwable cause) {
        log.error("获取充电桩统计数据远程服务调用失败:{}", cause.getMessage());
        return new RemoteMqttService() {
            @Override
            public Result<Boolean> setParameter(ParaDto paraDto, String source) {
                return Result.fail(false, "MQTT设置参数失败,服务降级");
            }
        };
    }
}
